/* GUI CONVERTED from adadcga.p (converter v1.76) Mon Apr 21 19:43:22 2003 */
/* adadcga.p - ADDRESS CODE CHANGE -SUBPROGRAM                          */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.15.1.9 $                                                     */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 6.0      LAST MODIFIED: 05/09/91   BY: WUG  D635**/
/* REVISION: 7.0      LAST MODIFIED: 11/22/91   BY: afs *F056**/
/*                                   04/15/92   BY: afs *F397**/
/*                                   05/21/92   BY: afs *F516**/
/* REVISION: 7.3      LAST MODIFIED: 03/25/93   BY: afs *G875**/
/*                                   05/28/93   BY: MPP *GB39*/
/*                                   11/22/93   BY: afs *GH51**/
/*                                   03/22/94   BY: dpm *FL63**/
/*                                   06/02/94   BY: dpm *GK05**/
/*                                   07/05/94   BY: rmh *FP15**/
/*                                   09/26/94   BY: jzs *GM54*/
/*                                   04/24/95   BY: dxk *F0QW*/
/*                                   09/22/95   BY: rxm *G0XC*/
/*                                   01/24/96   BY: ame *F0WW*/
/* REVISION: 8.6      LAST MODIFIED: 10/22/96   BY: *K004* Kurt De Wit  */
/* REVISION: 8.6      LAST MODIFIED: 11/19/96   BY: *H0PD* Aruna Patil  */
/* REVISION: 8.6      LAST MODIFIED: 06/06/97   BY: *H0ZQ* Ajit Deodhar */
/* REVISION: 8.6      LAST MODIFIED: 10/23/97   BY: *J245* Aruna Patil  */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 03/10/98   BY: *H1JZ* Niranjan R.  */
/* REVISION: 8.6E     LAST MODIFIED: 06/12/98   BY: *L02D* Niranjan R.  */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.0      LAST MODIFIED: 03/10/99   BY: *M0B3* Michael Amaladhas  */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0KK* jyn                */
/* REVISION: 9.1      LAST MODIFIED: 09/21/00   BY: *L14D* Nikita Joshi       */
/* REVISION: 9.1      LAST MODIFIED: 02/06/01   BY: *N0VG* Jyoti Thatte       */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.15.1.7     BY: Katie Hilbert      DATE: 05/15/02  ECO: *P06H*  */
/* Revision: 1.15.1.8     BY: Rajiv Ramaiah      DATE: 10/16/02  ECO: *N1X6*  */
/* $Revision: 1.15.1.9 $    BY: Narathip W.        DATE: 04/17/03  ECO: *P0Q4*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */
{cxcustom.i "ADADCGA.P"}

define shared variable addr1     like ad_addr.
define shared variable addr2     like ad_addr.
define shared variable i         as integer no-undo.
define shared variable num_rec   as integer no-undo.
define shared variable cnt_clear like mfc_logical. /* mfcscgb.i */
define shared variable record_id as recid no-undo.
define shared variable type1     like ad_type.
define shared variable adtype    like ad_type.
define shared frame b.
define variable jk as integer.

define new shared temp-table temp_inactive no-undo
   fields temp_inactive_node like anx_node
   fields temp_inactive_code like anx_code.

{gpfilev.i}

for each temp_inactive
   exclusive-lock:
   delete temp_inactive.
end. /* FOR EACH temp_inactive */

do with frame b:

   {&ADADCGA-P-TAG1}
   FORM /*GUI*/   /* Standard code change form */
      file_desc    label "Data Set" format "x(30)"
      num_rec      label "Records Updated"
   with frame b width 80 down no-attr-space THREE-D /*GUI*/.

   {&ADADCGA-P-TAG2}

   /* SET EXTERNAL LABELS */
   setFrameLabels(frame b:handle).

   /* Updates for files beginning a-v */
   {gprun.i ""adadcgd.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   {gprun.i ""adadcgd1.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   /* FOR ADTYPE OTHER THAN SLSPRSN USE mfcscg.i WHICH WILL
   SUB-BRACKET ON NECESSARY RECORDS AND WILL USE INDEX tr_addr_eff */

   if adtype = "slsprsn" then do:
      {adadcg4.i tr_hist addr1 addr2 tr_addr tr_addr tr_addr
                "tr_slspsn" 4 " "}
   end. /* IF ADTYPE = "SLSPRSN" */
   else do:
      {mfcscg.i  tr_hist tr_addr addr1 addr2}
   end. /* ELSE DO */

   {mfcscg.i  glt_det glt_addr addr1 addr2}
   {mfcscg01.i  gltr_hist gltr_addr addr1 addr2}
   {adadcg4.i ih_hist addr1 addr2 ih_cust ih_bill ih_ship "ih_slspsn" 4 " "}

   {&ADADCGA-P-TAG3}
   /* REPLACED mfcscg.i WITH mfcscg01.i TO PREVENT LOCKING OF */
   /* UNRELATED sod_det RECORDS.                              */
   /* UPDATE BACK TO BACK FIELDS */
   {mfcscg01.i  sod_det  sod_btb_vend addr1 addr2}
   {mfcscg.i  idh_hist idh_btb_vend addr1 addr2}
   {mfcscg.i  si_mstr  si_btb_vend  addr1 addr2}

   /* Salesperson arrays -                                      */
   /* The only fields to be updated in the following files are  */
   /* are salesperson arrays.  Files which have other fields    */
   /* to be updated should be updated through adadcg3.i in the  */
   /* section above.                                            */
   if adtype = "slsprsn" then do:

      {adadcg5.i sod_det  addr1 addr2 "sod_slspsn" 4 " " }
      {adadcg5.i qod_det  addr1 addr2 "qod_slspsn" 4 " " }
      {adadcg5.i idh_hist addr1 addr2 "idh_slspsn" 4 " " }
      {adadcg5.i cm_mstr  addr1 addr2 "cm_slspsn"  4 " " }
   end.

   /*Update Shipto in  files of Release Management */
   {mfcscg.i  scx_ref scx_shipto addr1 addr2}

   /* REPLACED mfcscg.i WITH mfcscg01.i TO PREVENT LOCKING OF */
   /* UNRELATED sch_mstr RECORDS.                             */

   {mfcscg01.i sch_mstr sch_ship addr1 addr2}

   if adtype = "supplier"  then do:
      {mfcscg.i ptp_det ptp_vend addr1 addr2}
      {mfcscg.i scx_ref scx_shipfrom addr1 addr2}
   end.

   num_rec = 0.
   for each abs_mstr exclusive-lock
      where abs_shipfrom = addr1 or abs_shipto = addr1:
      /* CHANGE ADDRESSES ON SHIPPERS FOR SUPPLIER SCHEDULES */
      if abs_type = "R" and abs_shipfrom = addr1 then
         assign
            abs_shipfrom = addr2
            num_rec = num_rec + 1.
      else
      /* CHANGE ADDRESSES ON SHIPPERS FOR CUSTOMER SCHEDULES */
      if abs_type = "S" and abs_shipto = addr1 then
         assign
            abs_shipto = addr2
            num_rec = num_rec + 1.
   end.
   {mfcscgb.i abs_mstr} /* DISPLAY COUNT OF abs_mstr RECORDS CHANGED */

   /* DELETE OLD ADDRESS RECORDS FROM anx_det                    */
   num_rec = 0.
   for each anx_det
         where anx_type = "9"
         and   anx_node = addr1
      exclusive-lock:

      /* CREATING TEMP TABLE FOR NEW ADDRESS */
      if not anx_active
      then do:
         create temp_inactive.
         assign
            temp_inactive_node = addr2
            temp_inactive_code = anx_code.
      end. /* IF not anx_active */

      delete anx_det.
      num_rec = num_rec + 1.
   end. /* FOR EACH anx_det */

   /* REGENERATE ANALYSIS CODE DETAIL FOR NEW ADDRESS            */
   {gprun.i ""adcsgen.p"" "(input ""9"", input addr2)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   /* DISPLAY COUNT OF anx_det RECORDS UPDATED                   */
   if num_rec <> 0 then
   do:
      {mfcscgb.i anx_det}
      num_rec = 0.
   end. /* IF NUM_REC <> 0 */

end.
